home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Human Interface Toolbox / Tabs LDEF / Menus.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  2.1 KB  |  131 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        Menus.c
  3.  
  4.     Contains:    Handles the application's menus
  5.  
  6.     Written by: Chris White    
  7.  
  8.     Copyright:    Copyright © 1995-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 8/10/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23.  
  24. #pragma segment Core
  25.  
  26.  
  27. #ifndef __MENUS__
  28.     #include <Menus.h>
  29. #endif
  30.  
  31. #ifndef __WINDOWS__
  32.     #include <Windows.h>
  33. #endif
  34.  
  35. #ifndef __DIALOGS__
  36.     #include <Dialogs.h>
  37. #endif
  38.  
  39. #ifndef __TEXTUTILS__
  40.     #include <TextUtils.h>
  41. #endif
  42.  
  43. #ifndef __DESK__
  44.     #include <Desk.h>
  45. #endif
  46.  
  47.  
  48.  
  49.  
  50.  
  51. // Application includes
  52.  
  53. #ifndef __BAREBONES__
  54.     #include "BareBones.h"
  55. #endif
  56.  
  57. #ifndef __PROTOTYPES__
  58.     #include "Prototypes.h"
  59. #endif
  60.  
  61.  
  62.  
  63.  
  64. static void DoAppleCmds ( SInt16 theItem );
  65. static void DoFileCmds ( SInt16 theItem );
  66.  
  67.  
  68.  
  69.  
  70.  
  71. void MenuDispatch ( SInt32 menuResult )
  72. {
  73.     SInt16     theMenu = (menuResult >> 16);                    // menu selected
  74.     SInt16     theItem = (menuResult & 0x0000FFFF);               // item selected
  75.     
  76.     switch (theMenu)
  77.     {
  78.         case kAppleMenu: 
  79.             DoAppleCmds ( theItem );
  80.         break;
  81.         
  82.         case kFileMenu: 
  83.             DoFileCmds ( theItem );
  84.         break;
  85.         
  86.     }
  87.     
  88.     HiliteMenu ( 0 );               // un-hilite selected menu
  89.     
  90.     return;
  91.     
  92. } // MenuDispatch
  93.  
  94.  
  95.  
  96. static void DoAppleCmds ( SInt16 theItem )
  97. {
  98.     Str255    name;            // string for DA name
  99.     
  100.     
  101.     switch ( theItem )
  102.     {
  103.         case cAbout:
  104.             Alert ( kAboutDialog, nil );
  105.         break;
  106.         
  107.         default:
  108.             GetMenuItemText ( GetMenuHandle ( kAppleMenu ), theItem, (StringPtr) &name );
  109.             OpenDeskAcc ( (StringPtr) &name );
  110.         break;
  111.     }
  112. }
  113.  
  114.  
  115.  
  116. static void DoFileCmds ( SInt16 theItem )
  117. {    
  118.     switch ( theItem )
  119.     {
  120.         case cQuit:
  121.             gQuit = true;
  122.         break;
  123.     }
  124.     
  125.     return;
  126.     
  127. } // DoFileCmds
  128.  
  129.  
  130.  
  131.